<?php
declare(strict_types=1);

namespace App\Controller\Backend;

use App\Logic\AdminSettingLogic;
use Hyperf\HttpServer\Annotation\AutoController;
use Psr\Http\Message\ResponseInterface;

#[AutoController(prefix: '/setting', server: 'backend')]
class SettingController extends AbstractController
{
    /**
     * 配置清单
     * @return ResponseInterface
     */
    public function lists(): ResponseInterface
    {
        $setting = AdminSettingLogic::listSetting();
        return $this->apiReturn(200, 'succ', $setting);
    }

    /**
     * 保存配置
     * @return ResponseInterface
     */
    public function save(): ResponseInterface
    {
        $input = $this->request->all();
        AdminSettingLogic::saveSetting($input);
        return $this->apiReturn(200, '保存成功');
    }

    /**
     * 配置日志
     * @return ResponseInterface
     */
    public function logs(): ResponseInterface
    {
        $input = $this->request->all();
        return $this->apiReturn(200, 'succ', AdminSettingLogic::logSetting($input));
    }
}